
function updateClassInfo(tags, _array) {
	var _container = dojo.byId(tags+"_Container");
	var str = "";
	for(var i=0;i<_array.length;i++) {
		var href = window.basePath + "classify.do?classifier=" + tags + 
				   "&searchWord=" + _array[i].name + "&orderBy=price&isAsc=true&startIndex=0";
		str += "<li><a href='"+href+"'>" + _array[i].name + "</a></li>";
	}
	
	_container.innerHTML = str;
}

function updateHeadInfo(ajax_request) {
	var data = eval("(" + ajax_request.responseText + ")");
	
	var author_array = data.authors;
	var category_array = data.categories;
	
	updateClassInfo("categories", category_array);
	updateClassInfo("authors", author_array);
}

function updateCategoriesInAdvancedSearch(ajax_request) {
	var data = eval("(" + ajax_request.responseText + ")");
	for(var i=0; i<data.categories.length;i++) {
		var item ={
			name:data.categories[i].name
		}
		categoryStore.newItem(item);
	}
}

function initHead(){
	var href = "initHead.do?startIndex=0&authorMax=30&categoryMax=30"; 
	ajaxRequest(href, updateHeadInfo, null);
	
	// initial categories in advanced search form
	href = "showCategories.do";
	ajaxRequest(href, updateCategoriesInAdvancedSearch, null);
	
	// initial publish year
	for(var i=1980;i<=2009;i++) {
		var yearItem = {
			name:i
		}
		publishYearStore.newItem(yearItem);
	}
}

function initAdminHead() {
	// initial categories in advanced search form
	var href = "showCategories.do";
	ajaxRequest(href, updateCategoriesInAdvancedSearch, null);
	
	// initial publish year
	for(var i=1980;i<=2009;i++) {
		var yearItem = {
			name:i
		}
		publishYearStore.newItem(yearItem);
	}
}
